﻿using System.Data;
using System.Configuration;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;
using System.Text;
using System.Web.Services;


public partial class admin_add_new_client : System.Web.UI.Page
{
    DataTable table = new DataTable("Customers");
    string p_id = null;
    string c_id;
    string t_id;
   
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["p_id"] == null)
        {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var random = new Random();
            var p_id = new string(
                Enumerable.Repeat(chars, 8)
                          .Select(s => s[random.Next(s.Length)])
                          .ToArray());




            //Session["p_id"] = p_id;
            SqlConnection con = null;

            con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
            con.Open();


            SqlCommand cmd1 = new SqlCommand("SELECT p_id FROM property_buy where p_id='" + Session["p_id"] + "'", con);


            SqlDataReader dr2 = cmd1.ExecuteReader();


            if (dr2.Read())
            {
                var chars1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                var random1 = new Random();
                var n_id = new string(
                    Enumerable.Repeat(chars1, 8)
                              .Select(s => s[random1.Next(s.Length)])
                              .ToArray());


                Request.QueryString["p_id"] = n_id;

            }






            else
            {
                Session["p_id"] = p_id;

            }
            dr2.Close();
            con.Close();





        }

        else
        {
            p_id = Session["p_id"].ToString();
        }



        if (Session["t_id"] == null)
        {
            var chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var random2 = new Random();
            var t_id = new string(
                Enumerable.Repeat(chars2, 8)
                          .Select(s => s[random2.Next(s.Length)])
                          .ToArray());

            Session["t_id"] = t_id;
        }

        else
        {
            t_id = Session["t_id"].ToString();
        }
        //Session["myTable"] = table;
        if (!IsPostBack)
        {
            table.Columns.Add("action_");
            table.Columns.Add("p_id");
            table.Columns.Add("t_id");
            table.Columns.Add("deal_status");
            table.Columns.Add("created");
            table.Columns.Add("update_");
            table.Columns.Add("min_");
            table.Columns.Add("hrs");
            table.Columns.Add("fast_reminder");
            table.Columns.Add("day_");
            table.Columns.Add("hr");
            table.Columns.Add("min1");
            table.Columns.Add("agent");
            table.Columns.Add("sec_agent");
            table.Columns.Add("rank");
            table.Columns.Add("cust_rank");
            table.Columns.Add("commission");
            table.Columns.Add("sig");
            table.Columns.Add("refer");
            table.Columns.Add("cust_refer");
            table.Columns.Add("comment");
            table.Columns.Add("terms");
            table.Columns.Add("to_do");
            table.Columns.Add("cus_to_do");
            table.Columns.Add("status_");
            table.Columns.Add("full_day");
            table.Columns.Add("to_do_msg");
            table.Columns.Add("to_do_date");
            table.Columns.Add("to_hr");
            table.Columns.Add("to_min");
            table.Columns.Add("added_by");
            table.Columns.Add("cus_deal_status");
            table.Columns.Add("cust_stat");
            table.Columns.Add("cust_reminder");

        }


        if (Session["myTable"] == null)
        {
            Session["myTable"] = table;
        }

        else
        {


            table = Session["myTable"] as DataTable;

        }


        table = Session["myTable"] as DataTable;


        //TextBox16.Text = "0";

        if (Session["email"] == null)
        {
            Session["email"] = "admin";
        }
        // Label1.Text = Session["email"].ToString();
        // txtcreate.Text = System.DateTime.Now.ToString();
        txtagent.Text = Session["email"].ToString();


        //Session["type"] = DropDownList5.SelectedValue;
        //Session["proptype"] = DropDownList6.SelectedValue;
        //Label9.Text = Session["proptype"].ToString();
    }


    protected void ok(object sender, System.EventArgs e)
    {
        if (Session["t_id"] == null)
        {
            Random r1 = new Random();
            int num = r1.Next(0, 99999999); // generate random number
            string number = string.Format("{0:D8}", num);

            Random r2 = new Random();
            int num2 = r2.Next(0, 26); // generate random letter
            char letter = (char)('A' + num2);


            t_id = letter + number;
            Session["t_id"] = t_id;
        }

        else
        {
            t_id = Session["t_id"].ToString();
        }


        table.Rows.Add(p_id, p_id, t_id, DropDownList4.SelectedValue, txtdate.Text, txtupdate.Text, ddlhr.SelectedValue, ddlmint.SelectedValue, DropDownList521.SelectedValue, txtFR.Text, ddlhr0.SelectedValue, ddlmint0.SelectedValue, txtagent.Text, DropDownList6.SelectedValue, DropDownList53.SelectedValue, TextBox55.Text, txtcommsin.Text, DropDownList54.SelectedValue, DropDownList55.SelectedValue, TextBox56.Text, txtcomment.Text, txtterms.Text, DropDownList28.SelectedValue, txtdo.Text, DropDownList29.SelectedValue, DropDownList30.SelectedValue, txtmsg.Text, txttododate.Text, ddlhr1.SelectedValue, ddlmint1.SelectedValue, "Admin", TextBox53.Text, TextBox78.Text, TextBox54.Text);


        GridView1.DataSource = table;
        GridView1.DataBind();
        Session["myTable"] = table;

        string path1 = Server.MapPath("upload/" + Session["p_id"] + "/" + "Doc");
        if (!Directory.Exists(path1))
        {
            Directory.CreateDirectory(path1);
        }

        if (FileUpload2.HasFile)
        {

            HttpFileCollection hfc = Request.Files;
            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                if (hpf.ContentLength > 0)
                {
                    hpf.SaveAs(Server.MapPath("upload/" + Session["p_id"] + "/" + "Doc/" + System.IO.Path.GetFileName(hpf.FileName)));

                    SqlConnection co = null;
                    co = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
                    co.Open();

                    SqlCommand cmd = new SqlCommand("Insert into files values(@id,@FileName ,@FilePath )", co);
                    //id nvarchar (50),
                    //FileName nvarchar (50),
                    //FilePath nvarchar (50)


                    cmd.Parameters.AddWithValue("@id", Session["p_id"]);
                    cmd.Parameters.AddWithValue("@FileName", System.IO.Path.GetFileName(hpf.FileName));
                    cmd.Parameters.AddWithValue("@FilePath", ("upload/" + Session["p_id"] + "/" + "Doc/" + hpf.FileName));


                    cmd.ExecuteNonQuery();
                    co.Close();
                
                }
            }
        }


        DropDownList4.SelectedIndex = 0;
 txtdate.Text =""; 
 txtupdate.Text ="";
 ddlhr.SelectedIndex = 0;
 ddlmint1.SelectedIndex = 0;
 DropDownList52.SelectedIndex = 0;
 txtFR.Text ="";
 ddlhr0.SelectedIndex = 0;
 ddlmint0.SelectedIndex = 0;
 DropDownList54.SelectedIndex = 0;
 txtcommsin.Text ="";
 DropDownList54.SelectedIndex = 0;
 DropDownList55.SelectedIndex = 0;
 TextBox56.Text =""; 
 txtcomment.Text ="";
 txtterms.Text ="";
 DropDownList28.SelectedIndex = 0;
 txtdo.Text = "";
 DropDownList29.SelectedIndex = 0;
 DropDownList30.SelectedIndex = 0;
 txtmsg.Text =""; 
 txttododate.Text ="";
 ddlhr1.SelectedIndex = 0;
 ddlmint1.SelectedIndex = 0;

    }




    protected void Cancel_Click(object sender, System.EventArgs e)
    {
        //btnSave_Student.Visible = true;
    }

    protected void show_pnl(object sender, System.EventArgs e)
    {
        //btnSave_Student.Visible = true;
    }



    protected void Save_Click(object sender, System.EventArgs e)
    {




        if (table.Rows.Count < 1)
        {
            properties();


            fileupload2();

            task();

        }
        else
        {
            properties();


            fileupload2();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                string pid = table.Rows[i]["p_id"].ToString().Trim();
                string tid = table.Rows[i]["t_id"].ToString().Trim();
                string deal_status = table.Rows[i]["deal_status"].ToString().Trim();
                string created = table.Rows[i]["created"].ToString().Trim();
                string update_ = table.Rows[i]["update_"].ToString().Trim();
                string min_ = table.Rows[i]["min_"].ToString().Trim();
                string hrs = table.Rows[i]["hrs"].ToString().Trim();
                string fast_reminder = table.Rows[i]["fast_reminder"].ToString().Trim();
                string day_ = table.Rows[i]["day_"].ToString().Trim();
                string hr = table.Rows[i]["hr"].ToString().Trim();
                string min1 = table.Rows[i]["min1"].ToString().Trim();
                string agent = table.Rows[i]["agent"].ToString().Trim();
                string sec_agent = table.Rows[i]["sec_agent"].ToString().Trim();
                string rank = table.Rows[i]["rank"].ToString().Trim();
                string cust_rank = table.Rows[i]["cust_rank"].ToString().Trim();
                string commission = table.Rows[i]["commission"].ToString().Trim();
                string sig = table.Rows[i]["sig"].ToString().Trim();
                string refer = table.Rows[i]["refer"].ToString().Trim();
                string cust_refer = table.Rows[i]["cust_refer"].ToString().Trim();
                string comment = table.Rows[i]["comment"].ToString().Trim();
                string terms = table.Rows[i]["terms"].ToString().Trim();
                string to_do = table.Rows[i]["to_do"].ToString().Trim();
                string cus_to_do = table.Rows[i]["cus_to_do"].ToString().Trim();
                string status_ = table.Rows[i]["status_"].ToString().Trim();
                string full_day = table.Rows[i]["full_day"].ToString().Trim();
                string to_do_msg = table.Rows[i]["to_do_msg"].ToString().Trim();
                string to_do_date = table.Rows[i]["to_do_date"].ToString().Trim();
                string to_hr = table.Rows[i]["to_hr"].ToString().Trim();
                string to_min = table.Rows[i]["to_min"].ToString().Trim();
                string cus_deal_status = table.Rows[i]["cus_deal_status"].ToString().Trim();

                string cust_stat = table.Rows[i]["cust_stat"].ToString().Trim();
                string cust_reminder = table.Rows[i]["cust_reminder"].ToString().Trim();

                SqlConnection conn = null;
                conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
                conn.Open();


                SqlCommand cmd1 = new SqlCommand("insert into task (p_id,t_id,deal_status,created,update_,min_,hrs,fast_reminder,day_,hr,min1,agent,sec_agent,rank,cust_rank,commission,sig,refer,cust_refer,comment,terms,to_do,cus_to_do,status_,full_day,to_do_msg,to_do_date,to_hr,to_min,added_by,cus_deal_status,cust_stat,cust_reminder) values  (@p_id ,@t_id ,@deal_status ,@created ,@update_ ,@min_ ,@hrs ,@fast_reminder ,@day_ ,@hr ,@min1 ,@agent ,@sec_agent ,@rank ,@cust_rank ,@commission ,@sig ,@refer ,@cust_refer ,@comment ,@terms ,@to_do ,@cus_to_do ,@status_ ,@full_day ,@to_do_msg ,@to_do_date ,@to_hr ,@to_min,@added_by,@cus_deal_status,@cust_stat,@cust_reminder)", conn);
                cmd1.Parameters.AddWithValue("@p_id ", pid);
                cmd1.Parameters.AddWithValue("@t_id ", t_id);
                cmd1.Parameters.AddWithValue("@deal_status ", deal_status);
                cmd1.Parameters.AddWithValue("@created ", created);
                cmd1.Parameters.AddWithValue("@update_ ", update_);
                cmd1.Parameters.AddWithValue("@min_", min_);
                cmd1.Parameters.AddWithValue("@hrs", hrs);
                cmd1.Parameters.AddWithValue("@fast_reminder", fast_reminder);
                cmd1.Parameters.AddWithValue("@day_ ", day_);
                cmd1.Parameters.AddWithValue("@hr", hr);
                cmd1.Parameters.AddWithValue("@min1", min1);
                cmd1.Parameters.AddWithValue("@agent", agent);
                cmd1.Parameters.AddWithValue("@sec_agent", sec_agent);
                cmd1.Parameters.AddWithValue("@rank", rank);
                cmd1.Parameters.AddWithValue("@cust_rank", cust_rank);
                cmd1.Parameters.AddWithValue("@commission", commission);
                cmd1.Parameters.AddWithValue("@sig", sig);
                cmd1.Parameters.AddWithValue("@refer", refer);
                cmd1.Parameters.AddWithValue("@cust_refer", cust_refer);
                cmd1.Parameters.AddWithValue("@comment", comment);
                cmd1.Parameters.AddWithValue("@terms", terms);
                cmd1.Parameters.AddWithValue("@to_do", to_do);
                cmd1.Parameters.AddWithValue("@cus_to_do", cus_to_do);
                cmd1.Parameters.AddWithValue("@status_ ", status_);
                cmd1.Parameters.AddWithValue("@full_day", full_day);
                cmd1.Parameters.AddWithValue("@to_do_msg", to_do_msg);
                cmd1.Parameters.AddWithValue("@to_do_date", to_do_date);
                cmd1.Parameters.AddWithValue("@to_hr", to_hr);
                cmd1.Parameters.AddWithValue("@to_min", to_min);

                cmd1.Parameters.AddWithValue("@added_by", Session["email"]);
                cmd1.Parameters.AddWithValue("@cus_deal_status", cus_deal_status);
                cmd1.Parameters.AddWithValue("@cust_stat", cust_stat);

                cmd1.Parameters.AddWithValue("@cust_reminder", cust_reminder);




                cmd1.ExecuteNonQuery();
                GridView1.Columns.Clear();

                table.Clear();

                conn.Close();

                Session.Abandon();

                GridView1.Columns.Clear();

                table.Clear();
                Response.Redirect("propert_for_conf.aspx");
            }







           


           



        }
    }
    protected void LinkButton1_Click(object sender, System.EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("../admin.aspx");
    }
    protected void DropDownList4_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        //Session["type"] = DropDownList5.SelectedValue;
        //Session["proptype"] = DropDownList6.SelectedValue;

       
    }

    public void fileupload2()
    { 
if (FileUpload2.HasFile)
                {

            
                string path1 = Server.MapPath("upload/" + Session["p_id"] + "/" + "Doc");
                if (!Directory.Exists(path1))
                {
                    Directory.CreateDirectory(path1);
                }

                
                    HttpFileCollection hfc = Request.Files;
                    for (int i = 0; i < hfc.Count; i++)
                    {
                        HttpPostedFile hpf = hfc[i];
                        if (hpf.ContentLength > 0)
                        {
                            hpf.SaveAs(Server.MapPath("upload/" + Session["p_id"] + "/" + "Doc/" + System.IO.Path.GetFileName(hpf.FileName)));

                            SqlConnection co = null;
                            co = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
                            co.Open();

                            SqlCommand cmd2 = new SqlCommand("Insert into files values(@id,@FileName ,@FilePath )", co);
                            //id nvarchar (50),
                            //FileName nvarchar (50),
                            //FilePath nvarchar (50)


                            cmd2.Parameters.AddWithValue("@id", Session["p_id"]);
                            cmd2.Parameters.AddWithValue("@FileName", System.IO.Path.GetFileName(hpf.FileName));
                            cmd2.Parameters.AddWithValue("@FilePath", ("upload/" + Session["p_id"] + "/" + "Doc/" + hpf.FileName));


                            cmd2.ExecuteNonQuery();
                            co.Close();

                        }
                    }
                }



    }
    public void properties()
    {
        string cat = null;
        cat = DropDownList1.SelectedValue;



        SqlConnection conn = null;

        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();



        Random r1 = new Random();
        int num = r1.Next(0, 99999999); // generate random number
        string number = string.Format("{0:D8}", num);

        Random r2 = new Random();
        int num2 = r2.Next(0, 26); // generate random letter
        char letter = (char)('A' + num2);


        c_id = letter + number; // join both as ID 

        string p_size = TextBox11.Text + DropDownList7.SelectedValue;

        //  string balcony = DropDownList14.SelectedValue + TextBox6.Text;
        //  SqlCommand cmd = new SqlCommand("Insert into property_buy values(@p_id ,@type,@wants_to,@property,@c_type,@agent_name,@client_fullname,@property_type,@house_no,@city,@street,@ssn,@zip,@country,@email_id,@phone,@room_no,@floor,@store,@ac,@parking,@elevator,@price,@prop_size,@entering_date,@condtion,@balconies,@a_hours,@safe_room,@budget,@purpose,@nghrhood,@comment,@financing,@custom_name,@category,@c_cat,@cat,@adding_by,@date,@status,@detail)", conn);

        SqlCommand cmd = new SqlCommand("insert into property_buy values(@p_id,@type,@c_type,@custom_ctype,@a_nme,@p_type, @cust_p_type, @f_name, @l_name, @email_id, @phone, @house_no, @street,  @nghr,  @city,@country, @zip,  @p_city, @p_street, @p_nghr, @p_zip, @p_country, @f_roomno,  @from_floor,  @store, @to_roomno,  @to_floor,  @occupation,  @saferoom, @custom_saferoom, @garden,  @custom_garden,  @g_floor,  @custom_g_floor,  @ac, @custom_ac, @parking,@cust_parking, @elevator,@cust_elevator, @prop_cond, @cust_condtion,  @p_size, @p_size_type,@balconies,  @balconies_no,  @balcony_type,  @balconies1, @balconies_no1,@balcony_type1,  @a_hours, @furniture, @c_furn,  @purpose, @cust_purpose, @roof,  @cust_roof,  @finance,  @cust_finance, @budget,@currency_type, @mortage, @cust_mortage, @comment, @financing, @smart_house,  @alarm , @bars, @handicap,@guard,  @gym,  @jacuzie, @pool,  @check_custom,  @custom,@comments, @adding_by,  @date, @status, @city_2, @country_2 , @cust_store, @availability, @property_size)", conn);

        cmd.Parameters.AddWithValue("@p_id", Session["p_id"]);
        cmd.Parameters.AddWithValue("@type", "Buy");
        cmd.Parameters.AddWithValue("@c_type", DropDownList52.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_ctype", TextBox61.Text);
        cmd.Parameters.AddWithValue("@a_nme", DropDownList15.SelectedValue);
        cmd.Parameters.AddWithValue("@p_type", d6.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_p_type", txttype.Text);
        cmd.Parameters.AddWithValue("@f_name", txtfname1.Text);
        cmd.Parameters.AddWithValue("@l_name", txtlname1.Text);
        cmd.Parameters.AddWithValue("@email_id", TextBox22.Text);
        cmd.Parameters.AddWithValue("@phone", TextBox21.Text);
        cmd.Parameters.AddWithValue("@house_no", TextBox20.Text);
        cmd.Parameters.AddWithValue("@street", TextBox30.Text);
        cmd.Parameters.AddWithValue("@nghr", TextBox66.Text);
        cmd.Parameters.AddWithValue("@city", TextBox50.Text);
        cmd.Parameters.AddWithValue("@country", TextBox51.Text);
        cmd.Parameters.AddWithValue("@zip", TextBox52.Text);
        cmd.Parameters.AddWithValue("@p_city", TextBox23.Text);
        cmd.Parameters.AddWithValue("@p_street", TextBox26.Text);
        cmd.Parameters.AddWithValue("@p_nghr", TextBox27.Text);
        cmd.Parameters.AddWithValue("@p_zip", TextBox28.Text);
        cmd.Parameters.AddWithValue("@p_country", TextBox29.Text);
        cmd.Parameters.AddWithValue("@store", TextBox5.Text);
        cmd.Parameters.AddWithValue("@cust_store", DropDownList57.Text);
        cmd.Parameters.AddWithValue("@from_floor", TextBox561.Text);
        cmd.Parameters.AddWithValue("@to_floor", TextBox57.Text);
        cmd.Parameters.AddWithValue("@occupation", TextBox58.Text);
        cmd.Parameters.AddWithValue("@saferoom", DropDownList31.Text);
        cmd.Parameters.AddWithValue("@custom_saferoom", txtsaferoom.Text);
        cmd.Parameters.AddWithValue("@garden", DropDownList32.Text);
        cmd.Parameters.AddWithValue("@custom_garden", txtgarden.Text);
        cmd.Parameters.AddWithValue("@g_floor", DropDownList33.Text);
        cmd.Parameters.AddWithValue("@custom_g_floor", TextBox3.Text);
        cmd.Parameters.AddWithValue("@parking", DropDownList49.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_parking", TextBox59.Text);
        cmd.Parameters.AddWithValue("@elevator", DropDownList50.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_elevator", TextBox60.Text);
        cmd.Parameters.AddWithValue("@ac", DropDownList16.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_ac", TextBox9.Text);
        cmd.Parameters.AddWithValue("@prop_cond", DropDownList13.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_condtion", TextBox12.Text);
        cmd.Parameters.AddWithValue("@p_size", TextBox11.Text);
        cmd.Parameters.AddWithValue("@property_size", TextBox15.Text);
        cmd.Parameters.AddWithValue("@p_size_type", DropDownList7.SelectedValue);
        cmd.Parameters.AddWithValue("@balconies", txtBalconies.Text);
        cmd.Parameters.AddWithValue("@balconies_no", TextBox6.Text);
        cmd.Parameters.AddWithValue("@balcony_type", DropDownList46.SelectedValue);
        cmd.Parameters.AddWithValue("@balconies1", txtBalconies0.Text);
        cmd.Parameters.AddWithValue("@balconies_no1", TextBox48.Text);
        cmd.Parameters.AddWithValue("@balcony_type1", DropDownList47.SelectedValue);
        cmd.Parameters.AddWithValue("@a_hours", TextBox36.Text);
        cmd.Parameters.AddWithValue("@availability", TextBox10.Text);
        cmd.Parameters.AddWithValue("@furniture", DropDownList35.SelectedValue);
        cmd.Parameters.AddWithValue("@c_furn", TextBox16.Text);
        cmd.Parameters.AddWithValue("@purpose", DropDownList17.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_purpose", TextBox18.Text);
        cmd.Parameters.AddWithValue("@roof", DropDownList34.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_roof", TextBox23.Text);
        cmd.Parameters.AddWithValue("@finance", DropDownList18.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_finance", TextBox24.Text);
        cmd.Parameters.AddWithValue("@budget", TextBox35.Text);
        cmd.Parameters.AddWithValue("@currency_type", DropDownList51.SelectedValue);

        cmd.Parameters.AddWithValue("@mortage", DropDownList48.SelectedValue);

        cmd.Parameters.AddWithValue("@cust_mortage", TextBox31.Text);
        cmd.Parameters.AddWithValue("@comment", TextBox13.Text);
        cmd.Parameters.AddWithValue("@financing", DropDownList18.SelectedValue);

        cmd.Parameters.AddWithValue("@smart_house", CheckBox1.Checked);
        cmd.Parameters.AddWithValue("@alarm ", CheckBox2.Checked);
        cmd.Parameters.AddWithValue("@bars", CheckBox3.Checked);
        cmd.Parameters.AddWithValue("@handicap", CheckBox4.Checked);
        cmd.Parameters.AddWithValue("@guard", CheckBox5.Checked);
        cmd.Parameters.AddWithValue("@gym", CheckBox6.Checked);
        cmd.Parameters.AddWithValue("@jacuzie", CheckBox7.Checked);
        cmd.Parameters.AddWithValue("@pool", CheckBox8.Checked);
        cmd.Parameters.AddWithValue("@check_custom", CheckBox13.Checked);

        cmd.Parameters.AddWithValue("@custom", txtcheck.Text);

        cmd.Parameters.AddWithValue("@comments", TextBox13.Text);
        cmd.Parameters.AddWithValue("@adding_by", Session["email"]);
        cmd.Parameters.AddWithValue("@date", System.DateTime.Now);
        cmd.Parameters.AddWithValue("@status", "1");
        cmd.Parameters.AddWithValue("@city_2", TextBox25.Text);
        cmd.Parameters.AddWithValue("@country_2", TextBox67.Text);
        cmd.Parameters.AddWithValue("@f_roomno", TextBox541.Text);
        cmd.Parameters.AddWithValue("@to_roomno", TextBox551.Text);
      
        
        cmd.ExecuteNonQuery();
        conn.Close();
    }
    protected void Save1_Click(object sender, System.EventArgs e)
    {

    }

    public void task()
    {
        SqlConnection conn = null;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();

        SqlCommand cmd3 = new SqlCommand("insert into task (action_,p_id,t_id,deal_status,created,update_,hrs,min_,fast_reminder,day_,hr,min1,agent,sec_agent,rank,cust_rank,commission,sig,refer,cust_refer,comment,terms,to_do,cus_to_do,status_,full_day,to_do_msg,to_do_date,to_hr,to_min,added_by,cus_deal_status,cust_stat,cust_reminder) values  (@action_,@p_id ,@t_id ,@deal_status ,@created ,@update_ ,@min_ ,@hrs ,@fast_reminder ,@day_ ,@hr ,@min1 ,@agent ,@sec_agent ,@rank ,@cust_rank ,@commission ,@sig ,@refer ,@cust_refer ,@comment ,@terms ,@to_do ,@cus_to_do ,@status_ ,@full_day ,@to_do_msg ,@to_do_date ,@to_hr ,@to_min,@added_by,@cus_deal_status,@cust_stat,@cust_reminder)", conn);
        cmd3.Parameters.AddWithValue("@action_", "0");
        cmd3.Parameters.AddWithValue("@p_id ", Session["p_id"]);
        cmd3.Parameters.AddWithValue("@t_id ", Session["t_id"]);
        cmd3.Parameters.AddWithValue("@deal_status ", DropDownList4.SelectedValue);
        cmd3.Parameters.AddWithValue("@created ", txtdate.Text);
        cmd3.Parameters.AddWithValue("@update_ ", txtupdate.Text);
        cmd3.Parameters.AddWithValue("@hrs", ddlhr.SelectedValue);
        cmd3.Parameters.AddWithValue("@min_", ddlmint.SelectedValue);

        cmd3.Parameters.AddWithValue("@fast_reminder", DropDownList521.SelectedValue);
        cmd3.Parameters.AddWithValue("@day_ ", txtFR.Text);
        cmd3.Parameters.AddWithValue("@hr", ddlhr0.SelectedValue);
        cmd3.Parameters.AddWithValue("@min1", ddlmint0.SelectedValue);
        cmd3.Parameters.AddWithValue("@agent", txtagent.Text);
        cmd3.Parameters.AddWithValue("@sec_agent", DropDownList6.SelectedValue);
        cmd3.Parameters.AddWithValue("@rank", DropDownList53.SelectedValue);
        cmd3.Parameters.AddWithValue("@cust_rank", TextBox55.Text);
        cmd3.Parameters.AddWithValue("@commission", txtcommsin.Text);
        cmd3.Parameters.AddWithValue("@sig", DropDownList54.SelectedValue);
        cmd3.Parameters.AddWithValue("@refer", DropDownList55.SelectedValue);
        cmd3.Parameters.AddWithValue("@cust_refer", TextBox56.Text);
        cmd3.Parameters.AddWithValue("@comment", txtcomment.Text);
        cmd3.Parameters.AddWithValue("@terms", txtterms.Text);
        cmd3.Parameters.AddWithValue("@to_do", DropDownList28.SelectedValue);
        cmd3.Parameters.AddWithValue("@cus_to_do", txtdo.Text);
        cmd3.Parameters.AddWithValue("@status_ ", DropDownList29.SelectedValue);
        cmd3.Parameters.AddWithValue("@full_day", DropDownList30.SelectedValue);
        cmd3.Parameters.AddWithValue("@to_do_msg", txtmsg.Text);
        cmd3.Parameters.AddWithValue("@to_do_date", txttododate.Text);
        cmd3.Parameters.AddWithValue("@to_hr", ddlhr1.SelectedValue);
        cmd3.Parameters.AddWithValue("@to_min", ddlmint1.Text);

        cmd3.Parameters.AddWithValue("@added_by", Session["email"]);
        cmd3.Parameters.AddWithValue("@cus_deal_status", TextBox53.Text);
        cmd3.Parameters.AddWithValue("@cust_stat", TextBox78.Text);
        cmd3.Parameters.AddWithValue("@cust_reminder", TextBox54.Text);

        //cmd3.Parameters.AddWithValue("@cust_reminder", TextBox55.Text);
        cmd3.ExecuteNonQuery();

        conn.Close();
    }



//protected void  show_pnl();(object sender, System.EventArgs e)
//{

//}
protected void  Button4_Click(object sender, System.EventArgs e)
{
    
}

protected void CheckBox13_CheckedChanged(object sender, System.EventArgs e)
{
    Label1.Visible = true;
    //TextBox42.Visible = true;
}
protected void DropDownList28_SelectedIndexChanged(object sender, System.EventArgs e)
{

}
protected void DropDownList42_SelectedIndexChanged(object sender, System.EventArgs e)
{

}
protected void DropDownList48_SelectedIndexChanged(object sender, System.EventArgs e)
{
    

}
protected void txtcreate_TextChanged(object sender, System.EventArgs e)
{

}
}